//
//  ST_IntroMyselfViewController.swift
//  btvideo
//
//  Created by mac on 2019/11/11.
//  Copyright © 2019 JarvanZhang. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift

//关于我-controller
class ST_IntroMyselfViewController: ST_BTLightBarViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title_nav_btn.setTitleForAllStates("关于我")
        self.right_nav_btn.setTitleForAllStates("保存")
        
        right_nav_btn.setTitleColorForAllStates(Color.init(hexString: "#333333")!)
        
        self.view.addSubview(item1)
        self.view.addSubview(item2)
        self.view.addSubview(item3)
        
        
        item1.snp.makeConstraints { (make) in
            make.top.equalTo(self.own_navigation_bar.snp.bottom).offset(25)
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(160)
        }
        
        item2.snp.makeConstraints { (make) in
            make.top.equalTo(self.item1.snp.bottom).offset(20)
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(160)
        }
        
        item3.snp.makeConstraints { (make) in
            make.top.equalTo(self.item2.snp.bottom).offset(32)
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(160)
        }
        
        setup_data()
        
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        
        switch willEditIdx {
        case 1:
            self.item2.textView.becomeFirstResponder()
        case 2:
            self.item3.textView.becomeFirstResponder()
        default:
            self.item1.textView.becomeFirstResponder()
        }
        
    }
    
    var outside_text_array = [String]()
    
    var willEditIdx = 0
    
    var modify_closure:(([String])->())?
    
    fileprivate func setup_data()  {
        
        let model1 = ST_IntroEditViewModel.init(title: "我想认识的人是", text: outside_text_array[0], placeholder: "例如：幽默有趣，很阳光，和我一样喜欢听民谣！")
        
        let model2 = ST_IntroEditViewModel.init(title: "说说我自己", text: outside_text_array[1], placeholder: "例如：170cm，55kg，不算瘦。看起来不太聪明的亚子。")
        
        let model3 = ST_IntroEditViewModel.init(title: "我们可以聊聊", text: outside_text_array[2], placeholder: "例如：哈利波特！我超级想去大阪环球影城体验霍格沃兹的！")
        
        item1.model = model1
        
        item2.model = model2
        
        item3.model = model3
        
    }
    
    override func right_click() {
        
        let array = [item1.textView.text ?? "",item2.textView.text ?? "",item3.textView.text ?? ""]
        
        modify_closure?(array)
        
        self.goback_previous_controller()
    }
    
//    MARK: - Properties
    override var hidden_right_btn: Bool {
        set {
            super.hidden_right_btn = newValue
        }
        get {
            return false
        }
    }
    
    lazy var item1 = ST_introEditView()
    
    lazy var item2 = ST_introEditView()
    
    lazy var item3 = ST_introEditView()
    
    
}
